<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="70px">
     <!-- <el-form-item prop="deptId">
        <treeselect v-model="queryParams.deptId" :options="deptOptions" :show-count="true" placeholder="部门" style="width: 480px"/>
      </el-form-item> -->
      <el-form-item prop="storeId">
        <!-- <treeselect v-model="queryParams.storeId" :options="storeOptions" :show-count="true" placeholder="请选择仓库"
          style="width: 480px" size="mini"/> -->
          <el-select v-model="queryParams.storeId" placeholder="仓库" clearable size="small">
              <el-option v-for="dict in storeOptions" :key="dict.id" :label="dict.label"
                :value="dict.id" />
            </el-select>
      </el-form-item>
      <!-- <el-form-item prop="taskId">
        <el-input v-model="queryParams.taskNo" placeholder="订单编号" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->

      <el-form-item prop="wno">
        <el-input v-model="queryParams.wno" placeholder="入库单号" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>

      <!-- <el-form-item prop="type">
        <el-select v-model="queryParams.type" placeholder="类型" clearable size="small">
          <el-option v-for="dict in dict.type.wms_warehouse_type" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item> -->

     <!-- <el-form-item label="联系人" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入姓名" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->

      <!-- <el-form-item label="联系方式" prop="tel">
        <el-input v-model="queryParams.tel" placeholder="请输入联系方式" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
 -->
      <el-form-item prop="flag">
        <el-select v-model="queryParams.flag" placeholder="物流配送" clearable size="small">
          <el-option v-for="dict in dict.type.oms_in_delivery_type" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-date-picker v-model="daterangeCreateTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
          type="daterange" range-separator="-" start-placeholder="下单起始日期" end-placeholder="截止日期"></el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['wms:warehouse:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['wms:warehouse:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['wms:warehouse:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['wms:warehouse:export']">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-printer" size="mini" @click="showPrintList"
          v-hasPermi="['wms:putTask:add']">签收打印</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="warehouseList" @selection-change="handleSelectionChange" border stripe>
      <el-table-column type="selection" width="55" align="center" fixed="left"/>
      <el-table-column label="入库单号"  prop="wno" fixed="left" width="150">
        <template slot-scope="scope">
          <el-link type="primary" @click="handleInfo(scope.row)">{{scope.row.wno}}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="存放库区" prop="storeName" width="120" />
      <el-table-column label="部门" prop="deptName" min-width="260"/>
      <<!-- el-table-column label="姓名" prop="name" width="100"/>
      <el-table-column label="联系方式"  prop="tel" width="120"/> -->
      <el-table-column label="物品数量" align="center" prop="taskNums" width="100"/>
      <!-- <el-table-column label="类型" align="center" prop="type" width="100">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.wms_warehouse_type" :value="scope.row.type" />
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="图片附件" align="center" prop="pics" /> -->
<!--     <el-table-column label="状态" align="center" prop="delFlag">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_del_flag" :value="scope.row.delFlag" />
        </template>
      </el-table-column> -->
      <el-table-column label="物流配送" align="center" prop="flag" width="180">
       <template slot-scope="scope">
         <dict-tag :options="dict.type.oms_in_delivery_type" :value="scope.row.flag" />
       </template>
      </el-table-column>
      <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleInfo(scope.row)"
            v-hasPermi="['oms:task:edit']">查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
      <el-drawer :title="title" :visible.sync="open" size="75%" :before-close="close">
        <div class="mb20 ml20">
          <span style="font-size: 20px;">{{form.wno}}</span>
          <div class="fr mr10">
            <el-button type="warning" :loading="refreshLoading" size="mini" @click="handleRefresh(form)" v-hasPermi="['super:warehouse:reload']">重载</el-button>
            <el-button type="primary" size="mini" @click="handleUpdate(form)">编辑</el-button>
            <el-button  size="mini" @click="handlePutTask(form)">上架</el-button>
            <el-button  size="mini" v-if="form.isValidate == '1'" @click="handleAck(form)">确认</el-button>
            <el-button type="danger" size="mini" @click="handleDelete(form)">删除</el-button>
          </div>
        </div>
        <el-card>
          <el-tabs value="1">
            <el-tab-pane label="申请详情" name="1">
              <el-card>
                <el-descriptions title="基本信息" :column="4" border>
                  <el-descriptions-item :label="taskForm.delivery == '0' ? '寄件单位':'送件单位'"
                    :span="2">{{taskForm.deptName}}</el-descriptions-item>
                  <el-descriptions-item :label="taskForm.delivery == '0' ? '寄件人':'送件人'">{{taskForm.name}}</el-descriptions-item>
                  <el-descriptions-item label="联系电话">{{taskForm.tel}}</el-descriptions-item>
                  <el-descriptions-item v-if="taskForm.delivery == '0'" label="寄件地址"
                    :span="4">{{taskForm.address}}</el-descriptions-item>
                  <el-descriptions-item label="物证类型">
                    <dict-tag :options="dict.type.oms_property_type" :value="taskForm.propertyType" />
                  </el-descriptions-item>
                  <el-descriptions-item label="物流配送">
                    <dict-tag :options="dict.type.oms_in_delivery_type" :value="taskForm.delivery" />
                  </el-descriptions-item>
                  <el-descriptions-item label="物品数量">{{taskForm.nums}}</el-descriptions-item>
                  <el-descriptions-item label="入库仓库">{{taskForm.storeName}}</el-descriptions-item>
                  <el-descriptions-item label="有无钥匙" v-if="taskForm.carKey">{{taskForm.carKey}}</el-descriptions-item>
                  <el-descriptions-item label="有无行驶证" v-if="taskForm.driveLicen">{{taskForm.driveLicen}}</el-descriptions-item>
                  <el-descriptions-item label="无" v-if="taskForm.othreNone">{{taskForm.othreNone}}</el-descriptions-item>
                  <el-descriptions-item label="申请备注" :span="4">{{taskForm.remark}}</el-descriptions-item>
                  <el-descriptions-item label="附件" :span="4">
                    <el-image v-if="taskForm.oss && taskForm.oss.length > 0" v-for="(pic,pindex) in taskForm.oss"
                      style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                      :preview-src-list="ossTransfer(taskForm.oss,'list')"></el-image>
                  </el-descriptions-item>
                </el-descriptions>
              </el-card>
              <handover-order :form="taskForm" :handoverOptions="handoverOptions" v-if="handoverOptions == null || handoverOptions.length == 0"></handover-order>
            </el-tab-pane>
            <el-tab-pane label="物品清单" name="2">
              <el-table :data="taskForm.items" border stripe>
                <el-table-column type="index" width="55" align="center"></el-table-column>
                <el-table-column label="物品编号" align="left" prop="pno" width="260">
                  <template slot-scope="scope">
                    <span>{{scope.row.pno}}</span>
                  </template>
                </el-table-column>
                <el-table-column label="物品名称" align="left" prop="name" width="200">
                  <template slot-scope="scope">
                    <span>{{scope.row.name}}</span>
                  </template>
                </el-table-column>
                <el-table-column label="数量" align="center" prop="nums" width="75">
                  <template slot-scope="scope">
                    <span>{{scope.row.nums}}</span>
                  </template>
                </el-table-column>
                <el-table-column label="图片" align="left" prop="oss">
                  <template slot-scope="scope">
                    <el-image v-if="scope.row.oss && scope.row.oss.length > 0" v-for="(pic,pindex) in scope.row.oss"
                      style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                      :preview-src-list="ossTransfer(scope.row.oss,'list')"></el-image>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="交接信息" name="3" v-if="handoverOptions && handoverOptions.length > 0">
            <handover-order :form="taskForm" :handoverOptions="handoverOptions" v-if="handoverOptions && handoverOptions.length > 0"></handover-order>
            </el-tab-pane>
            <el-tab-pane label="交接原件" name="4" v-if="handoverOssList && handoverOssList.length > 0">
              <el-image v-for="(pic,pindex) in handoverOssList" style="width: 100%;" :src="ossTransfer(pic,'list')"
                fit="scale-down" :preview-src-list="ossTransfer(handoverOssList,'list')"></el-image>
            </el-tab-pane>
            <el-tab-pane label="配送信息" name="5" v-if="orderOptions">
              <el-tabs tab-position="left" value="wayOrder">
                <el-tab-pane label="订单信息" name="wayOrder">
                  <el-descriptions title="基本信息" :column="3" border>
                    <el-descriptions-item label="订单编号">{{orderOptions.orderNo}}</el-descriptions-item>
                    <el-descriptions-item label="所属部门">{{orderOptions.deptName}}</el-descriptions-item>
                    <el-descriptions-item label="物品数量">{{orderOptions.nums}}</el-descriptions-item>
                    <el-descriptions-item label="客户名称"
                      v-if="orderOptions.clientName">{{orderOptions.clientName}}</el-descriptions-item>
                    <el-descriptions-item label="联系人"
                      v-if="orderOptions.clientContacts">{{orderOptions.clientContacts}}</el-descriptions-item>
                    <el-descriptions-item label="联系电话"
                      v-if="orderOptions.clientTel">{{orderOptions.clientTel}}</el-descriptions-item>
                    <el-descriptions-item label="备注" :span="3">{{orderOptions.memo}}</el-descriptions-item>
                  </el-descriptions>
                  <el-descriptions title="寄收地址" :column="3" border style="margin-top: 15px;">
                    <el-descriptions-item label="寄件单位">{{orderOptions.sendAddr}}</el-descriptions-item>
                    <el-descriptions-item label="寄件联系人">{{orderOptions.sendContacts}}</el-descriptions-item>
                    <el-descriptions-item label="联系方式">{{orderOptions.sendTel}}</el-descriptions-item>
                    <el-descriptions-item label="寄件地址" :span="3">{{orderOptions.sendAddress}}</el-descriptions-item>
                    <el-descriptions-item label="收件单位">{{orderOptions.takeAddr}}</el-descriptions-item>
                    <el-descriptions-item label="收件联系人">{{orderOptions.takeContacts}}</el-descriptions-item>
                    <el-descriptions-item label="联系方式">{{orderOptions.takeTel}}</el-descriptions-item>
                    <el-descriptions-item label="收件地址" :span="3">{{orderOptions.takeAddress}}</el-descriptions-item>
                  </el-descriptions>
                  <el-card style="margin-top: 15px;">
                    <div slot="header" class="clearfix">
                      <span style="font-weight: bold;">物品清单</span>
                    </div>
                    <el-table :data="orderOptions.items">
                      <el-table-column label="编号" prop="pno" />
                      <el-table-column label="名称" prop="name" />
                      <el-table-column label="数量" prop="nums" />
                    </el-table>
                  </el-card>
                  <el-card v-if="form.buss == '1'">
                    <div slot="header" class="clearfix">
                      <span>车辆附件</span>
                    </div>
                    <el-card class="fl mr10 mb10" style="width: 32%">
                          <div slot="header" class="clearfix">
                            <span>全车外观正前</span>
                          </div>
                            <el-image v-if="orderOptions.facadeOss && orderOptions.facadeOss.length > 0" v-for="(pic,pindex) in orderOptions.facadeOss"
                            style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                            :preview-src-list="ossTransfer(orderOptions.facadeOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                          <div slot="header" class="clearfix">
                            <span>全车外观正左</span>
                          </div>
                            <el-image v-if="orderOptions.facadeLeftOss && orderOptions.facadeLeftOss.length > 0" v-for="(pic,pindex) in orderOptions.facadeLeftOss"
                            style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                            :preview-src-list="ossTransfer(orderOptions.facadeLeftOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                          <div slot="header" class="clearfix">
                            <span>全车外观正后</span>
                          </div>
                            <el-image v-if="orderOptions.facadeAfterOss && orderOptions.facadeAfterOss.length > 0" v-for="(pic,pindex) in orderOptions.facadeAfterOss"
                            style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                            :preview-src-list="ossTransfer(orderOptions.facadeAfterOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                          <div slot="header" class="clearfix">
                            <span>全车外观正右</span>
                          </div>
                            <el-image v-if="orderOptions.facadeRightOss && orderOptions.facadeRightOss.length > 0" v-for="(pic,pindex) in orderOptions.facadeRightOss"
                            style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                            :preview-src-list="ossTransfer(orderOptions.facadeRightOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                          <div slot="header" class="clearfix">
                            <span>仪表盘</span>
                          </div>
                            <el-image v-if="orderOptions.dashboardOss && orderOptions.dashboardOss.length > 0" v-for="(pic,pindex) in orderOptions.dashboardOss"
                            style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                            :preview-src-list="ossTransfer(orderOptions.dashboardOss,'list')"></el-image>
                      </el-card>

                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>车架号</span>
                        </div>
                          <el-image v-if="orderOptions.carOss && orderOptions.carOss.length > 0" v-for="(pic,pindex) in orderOptions.carOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.carOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>交接现场</span>
                        </div>
                          <el-image v-if="orderOptions.handoverOss && orderOptions.handoverOss.length > 0" v-for="(pic,pindex) in orderOptions.handoverOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.handoverOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%" v-if="orderOptions.loadOss && orderOptions.loadOss.length > 0">
                        <div slot="header" class="clearfix">
                          <span>45度装车</span>
                        </div>
                          <el-image v-if="orderOptions.loadOss && orderOptions.loadOss.length > 0" v-for="(pic,pindex) in orderOptions.loadOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.loadOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>外观瑕疵</span>
                        </div>
                          <el-image v-if="orderOptions.flawOss && orderOptions.flawOss.length > 0" v-for="(pic,pindex) in orderOptions.flawOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.flawOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>到达目的地</span>
                        </div>
                          <el-image v-if="orderOptions.takeOss && orderOptions.takeOss.length > 0" v-for="(pic,pindex) in orderOptions.takeOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.takeOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>卸车</span>
                        </div>
                          <el-image v-if="orderOptions.unloadOss && orderOptions.unloadOss.length > 0" v-for="(pic,pindex) in orderOptions.unloadOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.unloadOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>其他</span>
                        </div>
                          <el-image v-if="orderOptions.otherOss && orderOptions.otherOss.length > 0" v-for="(pic,pindex) in orderOptions.otherOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.otherOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>其他</span>
                        </div>
                          <el-image v-if="orderOptions.otherTwoOss && orderOptions.otherTwoOss.length > 0" v-for="(pic,pindex) in orderOptions.otherTwoOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.otherTwoOss,'list')"></el-image>
                      </el-card>
                  </el-card>
                </el-tab-pane>
                <el-tab-pane label="运单信息"  name="wayBill" v-if="orderOptions.wayItems && orderOptions.wayItems.length > 0">
                  <template v-for="item in orderOptions.wayItems">
                    <el-steps :active="item.status == 2?0:(item.status == 3?1:(item.status == 5?2:3))" align-center
                      process-status="finish" finish-status="success" simple style="margin-bottom: 10px;">
                      <el-step title="发车"></el-step>
                      <el-step title="到达"></el-step>
                      <el-step title="签收"></el-step>
                      <el-step title="完成"></el-step>
                    </el-steps>
                    <el-tabs value="1">
                      <el-tab-pane label="基本信息" name="1">
                        <el-descriptions :column="3" border>
                          <el-descriptions-item label="运单编号">{{item.waybillNo}}</el-descriptions-item>
                          <el-descriptions-item label="线路">{{item.lineName}}</el-descriptions-item>
                          <el-descriptions-item label="车次">{{item.scheduleName}}</el-descriptions-item>
                          <el-descriptions-item label="车牌号">{{item.carNumber}}</el-descriptions-item>
                          <el-descriptions-item label="司机" :span="2">{{item.driverName}}</el-descriptions-item>
                          <el-descriptions-item label="物品数量">{{item.nums}}</el-descriptions-item>
                        </el-descriptions>
                      </el-tab-pane>
                      <el-tab-pane label="物品清单" name="2">
                        <el-card>
                          <el-table :data="item.items">
                            <el-table-column label="编号" prop="pno" />
                            <el-table-column label="名称" prop="name" />
                            <el-table-column label="数量" prop="nums" />
                          </el-table>
                        </el-card>

                      </el-tab-pane>
                      <el-tab-pane label="日志跟踪" name="3">
                        <el-card>
                          <el-table :data="item.logItems">
                            <el-table-column label="操作人" prop="operator" />
                            <el-table-column label="节点名称">
                              <template slot-scope="scope">
                                <dict-tag :options="dict.type.tms_track_log_type" :value="scope.row.type" />
                              </template>
                            </el-table-column>
                            <el-table-column label="操作时间" prop="createTime"></el-table-column>
                            <el-table-column label="备注" prop="memeo" />
                          </el-table>
                        </el-card>
                      </el-tab-pane>
                    </el-tabs>
                  </template>
                </el-tab-pane>
              </el-tabs>
            </el-tab-pane>
            <el-tab-pane label="上架任务" name="6" v-if="putTaskOptions">
              <el-descriptions title="基本信息" :column="3" border style="margin-top: 15px;">
                <el-descriptions-item label="任务编号">{{putTaskOptions.taskNo}}</el-descriptions-item>
                <el-descriptions-item label="上架员">{{putTaskOptions.nickName}}</el-descriptions-item>
                <el-descriptions-item label="状态">
                  <dict-tag :options="dict.type.wms_put_task_status" :value="putTaskOptions.status" />
                </el-descriptions-item>
              </el-descriptions>
              <el-card style="margin-top: 15px;">
                <div slot="header" class="clearfix">
                  <span>物品清单</span>
                </div>
                <el-table :data="putTaskOptions.items">
                  <el-table-column label="编号" prop="pno" />
                  <el-table-column label="名称" prop="name" />
                  <el-table-column label="数量" prop="nums" />
                  <el-table-column label="状态" prop="nums">
                    <template slot-scope="scope">
                      <dict-tag :options="dict.type.wms_put_task_status" :value="scope.row.status" />
                    </template>
                  </el-table-column>
                </el-table>
              </el-card>
            </el-tab-pane>
            <el-tab-pane label="操作日志" name="7">
              <el-table :data="logOptions" border stripe>
                <el-table-column label="序号" type="index" width="50" align="center" />
                <el-table-column label="操作时间" align="left" prop="logTime" width="180" />
                <el-table-column label="操作人" align="left" prop="operator" width="200" />
                <el-table-column label="操作内容" align="left" prop="content" />
              </el-table>
            </el-tab-pane>
          </el-tabs>
        </el-card>
      </el-drawer>
      <el-drawer
        title="签收打印"
        :visible.sync="showPrint"
        size="75%"
        :modal="false"
        direction="rtl">
        <template>
          <div style="padding: 15px;">

          <el-descriptions direction="vertical" border v-for="(task,index) in printTask" style="margin-bottom: 10px;">
            <el-descriptions-item label="任务名称">{{task.title}}</el-descriptions-item>
            <el-descriptions-item label="总数">{{task.totality}}</el-descriptions-item>
            <!-- <el-descriptions-item label="已执行">{{task.doneSum}}</el-descriptions-item> -->
            <!-- <el-descriptions-item label="当前执行">{{task.current}}</el-descriptions-item> -->
            <!-- <el-descriptions-item label="状态">
              <el-tag type="success" size="small" v-if="task.end">完成</el-tag>
              <el-tag type="warning" size="small" v-if="!task.end">执行中</el-tag>
            </el-descriptions-item> -->
            <!-- <el-descriptions-item label="操作时间" :span="2">{{task.startTime}}</el-descriptions-item>
            <el-descriptions-item label="完成时间" :span="2">{{task.endTime}}</el-descriptions-item> -->

            <!-- <el-descriptions-item label="备注" v-if="item.msg" :span="4">
              {{item.msg}}
            </el-descriptions-item> -->
            <el-descriptions-item label="操作">
              <el-button type="success" size="small" @click="restartProgress">刷新</el-button>
              <el-button type="primary" size="small" @click="batchPrints(index)">批量打印</el-button>
              <el-button type="warning" size="small" @click="finishPrint(task.key)">完成</el-button>
            </el-descriptions-item>
            <el-descriptions-item>
              <template v-for="(item,index) in task.objs" >
                <el-card class="fl mr10 mb10">
                  <el-descriptions :column="3" border :labelStyle="{'textAlign':'center'}">
                    <el-descriptions-item label="编号" :span="3">
                    {{item.pno}}
                    <qrcode-show ref="qrcodeShow" :datas="item" :updateTime="item.updateTime" :dataList="task.objs" :allPrint.sync="allPrint"></qrcode-show>
                    </el-descriptions-item>

                    <el-descriptions-item label="名称" :span="2">{{item.name}}</el-descriptions-item>
                    <el-descriptions-item label="数量" :span="1">{{item.nums}}</el-descriptions-item>
                    <el-descriptions-item label="仓库" :span="3" >{{item.storeName}}</el-descriptions-item>
                    <el-descriptions-item label="存放位置" :span="3">
                       <locator-select :datas.sync="item" @updatePutDtl="updatePutDtl"></locator-select>
                    </el-descriptions-item>
                    <el-descriptions-item label="附件" :span="3">
                         <el-image v-if="item.oss && item.oss.length > 0" v-for="(pic,pindex) in item.oss"
                         style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                         :preview-src-list="ossTransfer(item.oss,'list')"></el-image>
                    </el-descriptions-item>
                  </el-descriptions>
                </el-card>
              </template>
            </el-descriptions-item>
          </el-descriptions>
          </div>
        </template>
      </el-drawer>
  </div>
</template>

<script>
  import { treeselect } from "@/api/system/dept";
  import { storeTreeselect } from "@/api/wms/store";
  import { listWarehouse,getWarehouse,updateWarehouse,printProgresses,finishPrint } from "@/api/wms/warehouse";
  import {listHandover,listHandoverInfo} from '@/api/wms/handover'
  import {getPutTaskByTask,refreshWarehouse} from '@/api/wms/putTask'
  import {listOperatorLog} from "@/api/oms/operatorLog"
  import Treeselect from "@riophae/vue-treeselect";
  import {getTask} from "@/api/oms/task";
  import { listOss} from '@/api/system/oss'
  import {getOrderTask} from '@/api/tms/order';
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  import { updatePutDtl } from "@/api/wms/putDtl";
  import {htmlToPdf,htmlToPdfInfo} from "@/utils/pdf.js"
  export default {
    dicts:['oms_delivery_type','handover_dtl_status','oms_property_type','wms_put_task_status','oms_in_delivery_type'],
    components:{Treeselect},
    data(){
      return{
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        //详情展开
        open:false,
        title:'入库单详情',
        // 显示搜索条件
        showSearch: true,
        // 遮罩层
        loading: true,
        refreshLoading:false,
        // 总条数
        total: 0,
        // 入库单表格数据
        warehouseList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          taskId: undefined,
          storeId: undefined,
          wno: undefined,
          type: undefined,
          deptId: undefined,
          name: undefined,
          tel: undefined,
          address: undefined,
          flag: undefined,
          createTime: undefined,
          createBy: undefined,
          updateTime: undefined,
          updateBy: undefined,
          isSign: 1,
          isFinish:'0',
          delFlag:'0',
        },
        // 图片附件时间范围
        daterangeCreateTime: [],
        //部门数据
        deptOptions:[],
        //仓库数据
        storeOptions:[],
        //详情数据
        form:{},
        taskForm:{},
        //上架任务
        putTaskOptions:{},
        //交接信息
        handoverOptions:[],
        //操作日志
        logOptions:[],
        printTask:[],
        handoverOssList: [],
        //详情-订单
        orderOptions: {},
        showPrint:false,

        allPrint:false
      }
    },
    created(){
      this.getList();
      this.getTreeselect();
      this.getStoreTreeselect();
    },
    methods: {
      /** 查询入库单列表 */
      getList() {
        this.loading = true;
        this.queryParams.params = {};
        if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
          this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
          this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
        }
        if (null != this.daterangeUpdateTime && '' != this.daterangeUpdateTime) {
          this.queryParams.params["beginUpdateTime"] = this.daterangeUpdateTime[0];
          this.queryParams.params["endUpdateTime"] = this.daterangeUpdateTime[1];
        }
        listWarehouse(this.queryParams).then(response => {
          this.warehouseList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 查询部门下拉树结构 */
      getTreeselect() {
        treeselect().then(response => {
          this.deptOptions = response.data;
        });
      },
      /** 查询分类下拉树结构 */
      getStoreTreeselect() {
        storeTreeselect().then(response => {
          this.storeOptions = response.data;
        });
      },
      //查看详情
      handleInfo(row){
        getWarehouse(row.id).then(response => {
          this.form = response.data;
          getTask(response.data.taskId).then(response => {
            this.taskForm = response.data;
            //交接明细
            this.getHandover(this.taskForm.id);
            this.getOrderInfo(this.taskForm.id);
            this.getPutTaskInfo(this.taskForm.id);
            this.getLogs(this.taskForm.id);
            this.getHandoverOss(this.taskForm.id);
            this.open = true;
          })
        });
      },
      /** 查询订单信息 */
      getOrderInfo(id) {
        getOrderTask(id).then(response => {
          this.orderOptions = response.data;
        })
      },
      //上架任务
      getPutTaskInfo(id){
        getPutTaskByTask(id).then(response=>{
          this.putTaskOptions = response.data;
        })
      },
      /** 查询交接信息 */
      getHandover(id) {
        listHandoverInfo({
          'objid': id
        }).then(response => {
          this.handoverOptions = response.data;
        })
      },
      getHandoverOss(objid) {
        listOss({
          'objid': objid,
          'buss': 'handoverDtl'
        }).then(response => {
          console.info('getHandoverOss======>', response)
          this.handoverOssList = response.rows;
        })
      },
      //日志
      getLogs(id){
        listOperatorLog({"objid":id,"logType":"wms"}).then(response=>{
          this.logOptions = response.rows;
        })
      },
      //关闭
      close(){
        this.open = false;
      },
      //上架任务
      handlePutTask(row){
        this.close();
        this.$router.push({
          path: '/wms/warehouseInfo/putTask/'+row.id,
          query: {
            pageNum: this.queryParams.pageNum
          }
        })
      },
      //跨级确认
      handleAck(row){
        updateWarehouse({"id":row.id,"isValidate":"2"}).then(response => {
          this.$modal.msgSuccess("确认成功");
          this.update = false;
          this.getList();
          this.close();
        }).finally(() => {
          this.buttonLoading = false;
        });
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.daterangeCreateTime = [];
        this.daterangeUpdateTime = [];
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.$router.push({
          path: '/wms/warehouseInfo/add',
          query: {
            pageNum: this.queryParams.pageNum
          }
        })
      },
      /** 修改按钮操作 */
      handleUpdate(row){
        const id = row.id || this.ids;
        this.close();
        this.$router.push({
          path: '/wms/warehouseInfo/edit/'+id,
          query: {
            pageNum: this.queryParams.pageNum
          }
        })
      },
      handleRefresh(row){
          this.refreshLoading = true;
          refreshWarehouse(row).then(response=>{
            if(response.code == 200){
              this.$modal.msgSuccess("重载成功！");
            }
          }).finally(()=>{
            this.refreshLoading = false;
          })
      },

      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$modal.confirm('是否确认删除出入库订单编号为"' + ids + '"的数据项？').then(() => {
          this.loading = true;
          return delTask(ids);
        }).then(() => {
          this.loading = false;
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).finally(() => {
          this.loading = false;
        });
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('wms/warehouse/export', {
          ...this.queryParams
        }, `warehouse_${new Date().getTime()}.xlsx`)
      },
      showPrintList(){
        printProgresses().then(response=>{
          this.printTask = response.data;
        })
        this.showPrint = true;
      },
      batchPrints(index){
        this.$refs['qrcodeShow'][index].printOpen();
        this.allPrint = true;
      },
      updatePutDtl(item){
        console.info("items::",item);
        updatePutDtl(item).then(response => {
          item.qrcode = response.data.qrcode;
          this.$modal.msgSuccess("修改成功");
          this.showPrintList();
        });
      },
      finishPrint(uuid){
        console.info("items::",item);
        finishPrint(uuid).then(response => {
          this.showPrintList();
        });
      },
      restartProgress(){
        this.showPrintList();
      },
      getShowFour(length, item) {
        if (length == 1 && item.htype == '0') {
          this.isFour = true;
          return 6;
        } else {
          this.isFour = false;
          return 8;
        }

      },
      handlePrint(title){
        // const printOrder = this.$refs['printOrder'];
        htmlToPdf('#printOrder',title)
      },
      handlePrintInfo(title){
        htmlToPdfInfo("#printOrder");
      },
      handlePrintPre(title){
        // const printOrder = this.$refs['printOrder'];
        htmlToPdf('#printOrderPre',title)
      },
    },
  }
</script>

<style>
  #handoverCard.box-card .el-card__header {
     border-bottom-color: #000;
   }

   /**
   改变边框颜色
    */
    #handoverCard.box-card .el-table {
     border-bottom: 1px solid #000;
     border-right: 1px solid #000;
     margin: 0 auto;
   }

   #handoverCard.box-card .el-table th {
     border: 1px solid black !important;
     border-right: none !important;
     border-bottom: none !important;
   }

    #handoverCard.box-card .el-table td {
     border: 1px solid black;
     border-right: none !important;
   }
</style>
